# Calls getPDBImage.py for a list of PDB IDs
# See getPDBImage.py for documentation

import os, time, re

t_init = time.time()

comma = re.compile(", ")
word_char = re.compile("\w")

with open("protein_and_pdb_list.txt", "r") as input_file:
	for line in input_file:
		comma_split_line = comma.split(line)
		# If the line has a number or letter in the second position after the comma
		# Input file should have lines of form: (random identifier), PDB identifier
		if word_char.match(comma_split_line[1]):
			pdb_id = comma_split_line[1][0:4]
			protein = comma_split_line[0]
			print("Protein: " + protein + ", PDB: " + pdb_id)
			os.system("python getPDBImage.py --pdb_id " + pdb_id + " --protein " + protein)

total_time = time.time() - t_init
average_time = total_time/float(len(pdb_list))
print("Grand total time: %.2f s" % total_time)
print("Average time: %.2f s" % average_time)
